Skip to contentSkip to conversation

Change in openvpn[master]: Allow test-crypt to work without --secret argument

Openvpn-devel In review plaisthos (Code Review) 3 participants 22 messages Dec 11, 2025 – Dec 22, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1765453028000.I72947bd4f0213fd118327f740daeb1d86ae166de@...2715...

#1 lore raw

plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypt to work without --secret argument
......................................................................

Allow test-crypt to work without --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/options.c
M tests/t_lpback.sh

7 files changed, 75 insertions(+), 14 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/1

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index 882cf28..b6e513d 100644
@@ -439,13 +439,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -453,6 +453,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +44 -5

73 lines not on this page · raw message

src/openvpn/options.c +2 -6
index 2d1f740..b430065 100644
@@ -2283,11 +2283,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2701,7 +2697,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +1 -1
index 8ab3973..eb6a72f 100755
@@ -95,7 +95,7 @@
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#2 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without --secret argument

In reply to a message not in the archive

plaisthos has uploaded a new patch set (#2). ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without --secret argument
......................................................................

Allow test-crypto to work without --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/options.c
M tests/t_lpback.sh

7 files changed, 75 insertions(+), 14 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/2

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index 882cf28..b6e513d 100644
@@ -439,13 +439,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -453,6 +453,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +44 -5

73 lines not on this page · raw message

src/openvpn/options.c +2 -6
index 2d1f740..b430065 100644
@@ -2283,11 +2283,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2701,7 +2697,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +1 -1
index 8ab3973..eb6a72f 100755
@@ -95,7 +95,7 @@
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#3 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

plaisthos has uploaded a new patch set (#3). ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/options.c
M tests/t_lpback.sh

7 files changed, 59 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/3

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index 882cf28..b6e513d 100644
@@ -439,13 +439,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -453,6 +453,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +28 -0
index fc079e1..d0c507d 100644
@@ -2997,6 +2997,30 @@
 #endif
 }
 
+
+static void
+do_init_crypto_test(struct context *c, const unsigned int flags)
+{
+    const struct options *options = &c->options;
+    ASSERT(options->test_crypto);
+
+    init_crypto_pre(c, flags);
+
+    c->c2.crypto_options.flags |= CO_PACKET_ID_LONG_FORM;
+
+    ASSERT(!key_ctx_bi_defined(&c->c1.ks.static_key));
+
+    /* Init cipher and hash algorithm */
+    init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
+                  options->test_crypto, true);
+
+    generate_test_crypto_random_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
+                                    "test crypto key");
+
+    /* Get key schedule */
+    c->c2.crypto_options.key_ctx_bi = c->c1.ks.static_key;
+}
+
 /*
  * Static Key Mode (using a pre-shared key)
  */
@@ -3501,6 +3525,10 @@
     {
         do_init_crypto_static(c, flags);
     }
+    else if (c->options.test_crypto)
+    {
+        do_init_crypto_test(c, flags);
+    }
     else if (c->options.tls_server || c->options.tls_client)
     {
         do_init_crypto_tls(c, flags);
src/openvpn/options.c +2 -6
index 2d1f740..b430065 100644
@@ -2283,11 +2283,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2701,7 +2697,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +1 -1
index 8ab3973..eb6a72f 100755
@@ -95,7 +95,7 @@
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#4 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 3: Code-Review-1

(1 comment)

Patchset:

PS3:
please do also remove the

```
"${openvpn}" --genkey secret key.$$
```

etc. from t_lpback.sh then

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 11 Dec 2025 11:43:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#5 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 3: Code-Review-1

(1 comment)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/b759d66f_128a83d7?usp=email :
PS3, Line 3528: else if (c->options.test_crypto)
Why not do this test first and remove all handling of test-crypto from do_init_crypto_static?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 11 Dec 2025 11:46:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#6 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 3:

(1 comment)

Patchset:

PS3:

Quoted 1 line

please do also remove the […]

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Thu, 11 Dec 2025 11:46:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#7 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

Hello cron2, flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Code-Review-1 by cron2, Code-Review-1 by flichtenheld

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/options.c
M tests/t_lpback.sh

7 files changed, 60 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/4

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index 882cf28..b6e513d 100644
@@ -439,13 +439,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -453,6 +453,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +28 -0
index fc079e1..d0c507d 100644
@@ -2997,6 +2997,30 @@
 #endif
 }
 
+
+static void
+do_init_crypto_test(struct context *c, const unsigned int flags)
+{
+    const struct options *options = &c->options;
+    ASSERT(options->test_crypto);
+
+    init_crypto_pre(c, flags);
+
+    c->c2.crypto_options.flags |= CO_PACKET_ID_LONG_FORM;
+
+    ASSERT(!key_ctx_bi_defined(&c->c1.ks.static_key));
+
+    /* Init cipher and hash algorithm */
+    init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
+                  options->test_crypto, true);
+
+    generate_test_crypto_random_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
+                                    "test crypto key");
+
+    /* Get key schedule */
+    c->c2.crypto_options.key_ctx_bi = c->c1.ks.static_key;
+}
+
 /*
  * Static Key Mode (using a pre-shared key)
  */
@@ -3501,6 +3525,10 @@
     {
         do_init_crypto_static(c, flags);
     }
+    else if (c->options.test_crypto)
+    {
+        do_init_crypto_test(c, flags);
+    }
     else if (c->options.tls_server || c->options.tls_client)
     {
         do_init_crypto_tls(c, flags);
src/openvpn/options.c +2 -6
index 2d1f740..b430065 100644
@@ -2283,11 +2283,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2701,7 +2697,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#8 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

Hello cron2, flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email

to look at the new patch set (#5).

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method.

Also remove the call to do_init_crypto_static in test_crypto_thread. We already call do_init_crypto beforehand.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/options.c
M tests/t_lpback.sh

7 files changed, 60 insertions(+), 12 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/5

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index 882cf28..b6e513d 100644
@@ -439,13 +439,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -453,6 +453,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +28 -1
index fc079e1..5197c54 100644
@@ -2997,6 +2997,30 @@
 #endif
 }
 
+
+static void
+do_init_crypto_test(struct context *c, const unsigned int flags)
+{
+    const struct options *options = &c->options;
+    ASSERT(options->test_crypto);
+
+    init_crypto_pre(c, flags);
+
+    c->c2.crypto_options.flags |= CO_PACKET_ID_LONG_FORM;
+
+    ASSERT(!key_ctx_bi_defined(&c->c1.ks.static_key));
+
+    /* Init cipher and hash algorithm */
+    init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
+                  options->test_crypto, true);
+
+    generate_test_crypto_random_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
+                                    "test crypto key");
+
+    /* Get key schedule */
+    c->c2.crypto_options.key_ctx_bi = c->c1.ks.static_key;
+}
+
 /*
  * Static Key Mode (using a pre-shared key)
  */
@@ -3501,6 +3525,10 @@
     {
         do_init_crypto_static(c, flags);
     }
+    else if (c->options.test_crypto)
+    {
+        do_init_crypto_test(c, flags);
+    }
     else if (c->options.tls_server || c->options.tls_client)
     {
         do_init_crypto_tls(c, flags);
@@ -5045,7 +5073,6 @@
     init_verb_mute(c, IVM_LEVEL_1);
     context_init_1(c);
     next_connection_entry(c);
-    do_init_crypto_static(c, 0);
 
     frame_finalize_options(c, options);
 
src/openvpn/options.c +2 -6
index 2d1f740..b430065 100644
@@ -2283,11 +2283,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2701,7 +2697,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#9 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 4:

(1 comment)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/133004d8_d3bfcd06?usp=email :
PS3, Line 3528: else if (c->options.test_crypto)

Quoted 1 line

Why not do this test first and remove all handling of test-crypto from do_init_crypto_static?

So basically to currently still support the old mode that allows to use --secret to manually specify the key. When we remove --secret in OpenVPN 2.8 master brnach it is going away entirely anyway.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 11 Dec 2025 14:44:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#10 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 5:

(2 comments)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/08f7e7fe_7800d03f?usp=email :
PS3, Line 3528: else if (c->options.test_crypto)

Quoted 1 line

So basically to currently still support the old mode that allows to use --secret to manually specify […]

Acknowledged

File src/openvpn/options.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/c8f0900d_ef9eff0f?usp=email :
PS5, Line 2695: if (options->tls_server + options->tls_client + (options->shared_secret_file != NULL) > 1)
Since test_crypto does not imply shared_secret_file anymore should we add a check here that we do not combine --test-crypto with --tls-* ?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Dec 2025 10:54:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>

#11 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 5:

(1 comment)

File src/openvpn/options.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/8c44e18c_770dbb08?usp=email :
PS5, Line 2695: if (options->tls_server + options->tls_client + (options->shared_secret_file != NULL) > 1)

Quoted 1 line

Since test_crypto does not imply shared_secret_file anymore should we add a check here that we do no […]

I think if we do that we should add it for all the "standalone" keys like genkey, show-ciphers, show-tls, show-digest.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 15 Dec 2025 11:41:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#12 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

MaxF has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 5: Code-Review-2

(1 comment)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/1c6c2400_8ae3694e?usp=email :
PS5, Line 3002: do_init_crypto_test(struct context *c, const unsigned int flags) This function isn't called before do_test_crypto runs.

(Found by colleagues at Sentyron)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Dec 2025 11:44:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#13 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

Hello MaxF, cron2, flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email

to look at the new patch set (#6).

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method. This also removes the extra logic that is a leftover from the early multi-thread implementation attempt.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/openvpn.c
M src/openvpn/options.c
M tests/t_lpback.sh

9 files changed, 69 insertions(+), 39 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/6

Changes.rst +3 -0
index 32efbe7..1a92b94 100644
@@ -338,6 +338,9 @@
   (force egress = ingress interface) can be achieved with the new
   ``--multihome same-interface`` sub-option.
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index a9232ce..ed581b1 100644
@@ -427,13 +427,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -441,6 +441,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +34 -26

83 lines not on this page · raw message

src/openvpn/init.h +1 -1
index 97318ec..d5c8c04 100644
@@ -71,7 +71,7 @@
 
 void close_instance(struct context *c);
 
-bool do_test_crypto(const struct options *o);
+void do_test_crypto(struct context *o);
 
 void context_gc_free(struct context *c);
 
src/openvpn/openvpn.c +2 -1
index eaaa59b..0c22e27 100644
@@ -258,8 +258,9 @@
             pre_setup(&c.options);
 
             /* test crypto? */
-            if (do_test_crypto(&c.options))
+            if (c.options.test_crypto)
             {
+                do_test_crypto(&c);
                 break;
             }
 
src/openvpn/options.c +2 -6
index 34af0d3..22ec7fe 100644
@@ -2276,11 +2276,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2694,7 +2690,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#14 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: MaxF, cron2, flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 6:

(1 comment)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/5ca3c174_73dab1c5?usp=email :
PS5, Line 3002: do_init_crypto_test(struct context *c, const unsigned int flags)

Quoted 1 line

This function isn't called before do_test_crypto runs. […]

You are right. I am not entirely sure why it even worked.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Dec 2025 14:53:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: MaxF <[email protected]...>

#15 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: MaxF, cron2, flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 6:

(1 comment)

File src/openvpn/init.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/c8751373_284a2f3c?usp=email :
PS5, Line 3002: do_init_crypto_test(struct context *c, const unsigned int flags)

Quoted 1 line

You are right. I am not entirely sure why it even worked.

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Dec 2025 14:53:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: MaxF <[email protected]...>

#16 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

MaxF has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 6: Code-Review+1

(1 comment)

Patchset:

PS6:
The init function is called now, and I'm ok with this change. I'll leave the +2 to Frank because he still has an open discussion.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Dec 2025 14:08:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#17 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: MaxF, cron2, flichtenheld, plaisthos.

Hello MaxF, cron2, flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email

to look at the new patch set (#7).

The following approvals got outdated and were removed:
Code-Review+1 by MaxF

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method. This also removes the extra logic that is a leftover from the early multi-thread implementation attempt.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/openvpn.c
M src/openvpn/options.c
M tests/t_lpback.sh

9 files changed, 70 insertions(+), 39 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/7

Changes.rst +4 -0
index 048434d..c8a3058 100644
@@ -343,6 +343,10 @@
   loading for key/cert files with non-ASCII characters in their file names
   (GH: OpenVPN/openvpn#920).
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index a9232ce..ed581b1 100644
@@ -427,13 +427,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -441,6 +441,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +34 -26

83 lines not on this page · raw message

src/openvpn/init.h +1 -1
index 97318ec..d5c8c04 100644
@@ -71,7 +71,7 @@
 
 void close_instance(struct context *c);
 
-bool do_test_crypto(const struct options *o);
+void do_test_crypto(struct context *o);
 
 void context_gc_free(struct context *c);
 
src/openvpn/openvpn.c +2 -1
index eaaa59b..0c22e27 100644
@@ -258,8 +258,9 @@
             pre_setup(&c.options);
 
             /* test crypto? */
-            if (do_test_crypto(&c.options))
+            if (c.options.test_crypto)
             {
+                do_test_crypto(&c);
                 break;
             }
 
src/openvpn/options.c +2 -6
index 34af0d3..22ec7fe 100644
@@ -2276,11 +2276,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2694,7 +2690,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>

#18 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

Attention is currently required from: MaxF, cron2, plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Patch Set 7: Code-Review+2

(1 comment)

File src/openvpn/options.c:

http://gerrit.openvpn.net/c/openvpn/+/1435/comment/76bfcbc2_b234d8c7?usp=email :
PS5, Line 2695: if (options->tls_server + options->tls_client + (options->shared_secret_file != NULL) > 1)

Quoted 1 line

I think if we do that we should add it for all the "standalone" keys like genkey, show-ciphers, show […]

I'm okay with moving this change to a separate patch. It is not strictly required.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Dec 2025 16:25:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>

#19 lore raw

PATCH v7 1/1 Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method. This also removes the extra logic that is a leftover from the early multi-thread implementation attempt.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1435
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1435
This mail reflects revision 7 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

Changes.rst +4 -0
index 048434d..c8a3058 100644
@@ -343,6 +343,10 @@
   loading for key/cert files with non-ASCII characters in their file names
   (GH: OpenVPN/openvpn#920).
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index a9232ce..ed581b1 100644
@@ -427,13 +427,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -441,6 +441,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +34 -26

83 lines not on this page · raw message

src/openvpn/init.h +1 -1
index 97318ec..d5c8c04 100644
@@ -71,7 +71,7 @@
 
 void close_instance(struct context *c);
 
-bool do_test_crypto(const struct options *o);
+void do_test_crypto(struct context *o);
 
 void context_gc_free(struct context *c);
 
src/openvpn/openvpn.c +2 -1
index eaaa59b..0c22e27 100644
@@ -258,8 +258,9 @@
             pre_setup(&c.options);
 
             /* test crypto? */
-            if (do_test_crypto(&c.options))
+            if (c.options.test_crypto)
             {
+                do_test_crypto(&c);
                 break;
             }
 
src/openvpn/options.c +2 -6
index 34af0d3..22ec7fe 100644
@@ -2276,11 +2276,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2694,7 +2690,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e
#20 lore raw

[Openvpn-devel] [PATCH applied] Re: Allow test-crypto to work without the --secret argument

"make check" still passes :-) - not tested beyond, after sufficiently long and hard review and feedback from Max and Frank.

Your patch has been applied to the master branch.

commit 927b45dde7d75a08150fbe33b49892861f006e7f

Author: Arne Schwabe
Date:   Fri Dec 19 14:51:10 2025 +0100
     Allow test-crypto to work without the --secret argument

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1435
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg35157.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#21 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

cron2 has uploaded a new patch set (#8) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method. This also removes the extra logic that is a leftover from the early multi-thread implementation attempt.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1435
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35157.html

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/openvpn.c
M src/openvpn/options.c
M tests/t_lpback.sh

9 files changed, 70 insertions(+), 39 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1435/8

Changes.rst +4 -0
index 048434d..c8a3058 100644
@@ -343,6 +343,10 @@
   loading for key/cert files with non-ASCII characters in their file names
   (GH: OpenVPN/openvpn#920).
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index a9232ce..ed581b1 100644
@@ -427,13 +427,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -441,6 +441,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +34 -26

83 lines not on this page · raw message

src/openvpn/init.h +1 -1
index 97318ec..d5c8c04 100644
@@ -71,7 +71,7 @@
 
 void close_instance(struct context *c);
 
-bool do_test_crypto(const struct options *o);
+void do_test_crypto(struct context *o);
 
 void context_gc_free(struct context *c);
 
src/openvpn/openvpn.c +2 -1
index eaaa59b..0c22e27 100644
@@ -258,8 +258,9 @@
             pre_setup(&c.options);
 
             /* test crypto? */
-            if (do_test_crypto(&c.options))
+            if (c.options.test_crypto)
             {
+                do_test_crypto(&c);
                 break;
             }
 
src/openvpn/options.c +2 -6
index 34af0d3..22ec7fe 100644
@@ -2276,11 +2276,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2694,7 +2690,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#22 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Allow test-crypto to work without the --secret argument

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email )

Change subject: Allow test-crypto to work without the --secret argument
......................................................................

Allow test-crypto to work without the --secret argument

The --test-crypto still requires the --secret argument. Since --secret will be removed in OpenVPN 2.8 but we want to keep test-crypt, remove the dependency of test-crypto on --static.

Instead we will just generate a random key for this selftest method. This also removes the extra logic that is a leftover from the early multi-thread implementation attempt.

Change-Id I72947bd4f0213fd118327f740daeb1d86ae166de

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1435
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35157.html

---
M Changes.rst
M doc/man-sections/generic-options.rst
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/openvpn.c
M src/openvpn/options.c
M tests/t_lpback.sh

9 files changed, 70 insertions(+), 39 deletions(-)
Changes.rst +4 -0
index 048434d..c8a3058 100644
@@ -343,6 +343,10 @@
   loading for key/cert files with non-ASCII characters in their file names
   (GH: OpenVPN/openvpn#920).
 
+- The ``test-crypto`` option no longer requires a ``--secret`` argument and
+  will automatically generate a random key.
+
+
 Deprecated features
 -------------------
 ``--opt-verify`` feature removed
doc/man-sections/generic-options.rst +6 -2
index a9232ce..ed581b1 100644
@@ -427,13 +427,13 @@
   The typical usage of ``--test-crypto`` would be something like this:
   ::
 
-     openvpn --test-crypto --secret key
+     openvpn --test-crypto
 
   or
 
   ::
 
-     openvpn --test-crypto --secret key --verb 9
+     openvpn --test-crypto --verb 9
 
   This option is very useful to test OpenVPN after it has been ported to a
   new platform, or to isolate problems in the compiler, OpenSSL crypto
@@ -441,6 +441,10 @@
   problems with encryption and authentication can be debugged
   independently of network and tunnel issues.
 
+  Older versions of OpenVPN used the ``--secret`` argument to specify a
+  static key for this test. Newer version generate a random key for the
+  test.
+
 --tmp-dir dir
   Specify a directory ``dir`` for temporary files instead of the default
   :code:`TMPDIR` (or "/tmp" if unset). Note that it must be writable by the main
src/openvpn/crypto.c +12 -0
index e43bc6c..ddf3c17 100644
@@ -1325,6 +1325,18 @@
     secure_memzero(&key2, sizeof(key2));
 }
 
+void
+generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                const char *key_name)
+{
+    struct key2 key2;
+    key2.n = 2;
+    generate_key_random(&key2.keys[0]);
+    generate_key_random(&key2.keys[1]);
+    init_key_ctx_bi(ctx, &key2, KEY_DIRECTION_BIDIRECTIONAL, key_type, key_name);
+}
+
+
 /* header and footer for static key file */
 static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
 static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
src/openvpn/crypto.h +7 -0
index 9424fd7..6670deb 100644
@@ -632,6 +632,13 @@
                              const char *key_file, bool key_inline, const int key_direction,
                              const char *key_name, const char *opt_name, struct key2 *keydata);
 
+/**
+ * Generate a random key and initialise ctx to be used the in the crypto random
+ * test
+ */
+void generate_test_crypto_random_key(const struct key_type *key_type, struct key_ctx_bi *ctx,
+                                     const char *key_name);
+
 /*
  * Inline functions
  */
src/openvpn/init.c +34 -26

83 lines not on this page · raw message

src/openvpn/init.h +1 -1
index 97318ec..d5c8c04 100644
@@ -71,7 +71,7 @@
 
 void close_instance(struct context *c);
 
-bool do_test_crypto(const struct options *o);
+void do_test_crypto(struct context *o);
 
 void context_gc_free(struct context *c);
 
src/openvpn/openvpn.c +2 -1
index eaaa59b..0c22e27 100644
@@ -258,8 +258,9 @@
             pre_setup(&c.options);
 
             /* test crypto? */
-            if (do_test_crypto(&c.options))
+            if (c.options.test_crypto)
             {
+                do_test_crypto(&c);
                 break;
             }
 
src/openvpn/options.c +2 -6
index 34af0d3..22ec7fe 100644
@@ -2276,11 +2276,7 @@
 
     init_options(&defaults, true);
 
-    if (options->test_crypto)
-    {
-        notnull(options->shared_secret_file, "key file (--secret)");
-    }
-    else
+    if (!options->test_crypto)
     {
         notnull(options->dev, "TUN/TAP device (--dev)");
     }
@@ -2694,7 +2690,7 @@
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
-    if (!options->tls_server && !options->tls_client)
+    if (!options->tls_server && !options->tls_client && !options->test_crypto)
     {
         msglvl_t msglevel = M_USAGE;
         if (options->allow_deprecated_insecure_static_crypto)
tests/t_lpback.sh +2 -3
index 8ab3973..6802506 100755
@@ -89,13 +89,12 @@
 # Also test cipher 'none'
 CIPHERS=${CIPHERS}$(printf "\nnone")
 
-"${openvpn}" --genkey secret key.$$
 set +e
 
 for cipher in ${CIPHERS}
 do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --secret key.$$  --allow-deprecated-insecure-static-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -126,6 +125,6 @@
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
-rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$
+rm tc-server-key.$$ tc-client-key.$$ log.$$
 trap 0
 exit $e

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1435?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I72947bd4f0213fd118327f740daeb1d86ae166de
Gerrit-Change-Number: 1435
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>